1. Technical Field
The described embodiment relates generally to computer operations. More particularly, the described embodiment discloses guarded file descriptors used to prevent erroneous file operations and resultant data corruption.
2. Related Art
Computer based structured storage systems, such as computer file systems and database systems, have been remarkably successful at providing users with quick and easy access to enormous amounts of data. The importance of these structured storage systems in today's commerce is difficult to exaggerate. For example, structured storage systems have allowed businesses to generate and maintain enormous stores of persistent data that the company can modify and update over the course of years. For many companies, this persistent data is a valuable capital asset that is employed each day to perform the company's core operations. The data can be, for example, computer files (e.g., source code, word processing documents, etc.), database records and information (e.g., information on employees, customers, and/or products), and/or Web pages.
Applications can be built of many cooperating frameworks and libraries that share a dense namespace of file descriptors. The file descriptors take the form of a finite number of small integer values (enumerated as, for example, a 32 bit integer). These small integer values are used by a large family of application programming interfaces (“APIs”) that manipulate kernel abstractions such as files, sockets, shared memory, etc. If a particular library or framework opens a file descriptor on a private object (e.g., a database file), it can be disadvantageous for other code to access the file descriptor prior to the completion of the operation, since the other code can perform operations that can accidentally damage data associated with the file descriptors, file locks, and the underlying objects that they represent. As another example, sometimes the application can be hosting a “plug in” written by a third party, in which case care must be taken in how such file descriptors to files containing critical content are handled, since that code may be more vulnerable to code injection or other security compromises. For example, if an application opens a database file, a file descriptor having a numeric value such as “3” is returned to the application. The application can then write data to the file by referencing that file descriptor value. However, if another portion of the application, such as the plug in, performs a file operation such as a write or close using the file descriptor value 3, whether inadvertently or intentionally, the contents of the file and information related to the file, such as file locks, can become damaged. Therefore, what is desired is a more robust file descriptor system that can prevent damaging of file descriptors and associated data such as file locks, and the underlying objects.